function Polygon (points) {
    this.points = points;
}

Polygon.prototype = {
    constructor: Polygon,
    translate: function(point){
        for(var i =0 ; i < this.points.length ; i++){
            this.points[i].x += point.x;
            this.points[i].y += point.y;
        }
        return this;
    },
    scale: function(ratio){
        for(var i =0 ; i < this.points.length ; i++){
            this.points[i].x *= ratio;
            this.points[i].y *= ratio;
        }
        return this;
    },
    rotate: function(radius,pivot){
        var pivot = (pivot != null ? pivot : new Point(0,0));
        var radius = Math.PI * radius / 180;
        for(var i =0 ; i < this.points.length ; i++){
            var x = this.points[i].x;
            var y = this.points[i].y;
            this.points[i].x = pivot.x + (x - pivot.x) * Math.cos(radius) - (y - pivot.y) * Math.sin(radius);
            this.points[i].y = pivot.y + (x - pivot.x) * Math.sin(radius) + (y - pivot.y) * Math.cos(radius);
        }
        return this;
    }
}